<script setup lang="ts">

import {ref,defineProps} from 'vue'
import {onLoad,onShareAppMessage,onShareTimeline} from '@dcloudio/uni-app'
import {useSettingStore} from '@/store/setting'
import {getDetail} from '@/api/dealer'
import myParse from '@/components/loading-parse'
import IndexTitle from '@/pages/walls/index-title.vue'
import useShare from '@/mixins/share'
import {shareUtils} from '@/utils/share'
const {getShareCover} = useShare()
const store = useSettingStore()

const props = defineProps({
  id:{
    type:String
  }
})

const data = ref([])

onLoad((options)=>{
  
  getDetail(options.id).then(res=>{
    data.value = res
  })
})


const page = getCurrentPages().pop()
let path: string = `${page.route}?id=${props.id}`

const share_path = shareUtils.buildPathQuery(path)
onShareAppMessage(() => {

  const promise = new Promise(resolve => {
    getShareCover(path, null, null).then(res => {

      res.path = share_path

      debugger
      resolve(res)

    })
  })

  return {
    path: share_path,
    imageUrl: null,
    promise
  }
})



onShareTimeline(() => {

  const promise = new Promise(resolve => {
    getShareCover(path, null, null).then(res => {

      res.path = share_path

      debugger
      resolve(res)

    })
  })

  return {
    path: share_path,
    imageUrl: null,
    promise
  }
})


</script>

<template>
  <ForOneHeader />
  <MidLayout>
   
    <view v-for="item,index in data">
    <IndexTitle :zh_text="item.title" :en_text="item.en_title"/>
    <myParse :content="item.content" v-if="item.content"/>
  </view>
  </MidLayout>
</template>

<style scoped lang="scss"></style>
